4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
11 // You must not remove this notice, or any other, from this software.
15 // Macro.C - contains routines that have to do with macros
18 // Contains routines that have to do with macros
25 static STRINGLIST
**lastMacroChain
= NULL
;
27 // findMacro - look up a string in a hash table
29 // Look up a macro name in a hash table and return the entry
31 // If a macro and undefined, return NULL.
33 MACRODEF
* findMacro(char *str
)
40 for (n
= 0; *string
; n
+= *string
++); //Hash
42 #if defined(STATISTICS)
45 lastMacroChain
= (STRINGLIST
**)¯oTable
[n
];
46 for (found
= *lastMacroChain
; found
; found
= found
->next
) {
47 #if defined(STATISTICS)
50 if (!_tcscmp(found
->text
, str
)) {
51 return((((MACRODEF
*)found
)->flags
& M_UNDEFINED
) ? NULL
: (MACRODEF
*)found
);
55 // set lastMacroChain, even for an empty name
56 lastMacroChain
= (STRINGLIST
**)¯oTable
[0];
63 // Macro insertion requires that we JUST did a findMacro, which action set lastMacroChain.
65 void insertMacro(STRINGLIST
* p
)
70 assert(lastMacroChain
!= NULL
);
71 prependItem(lastMacroChain
, p
);
72 lastMacroChain
= NULL
;
75 // Init the macro table to a known state before continuing.
77 void initMacroTable(MACRODEF
*table
[])
80 for (num
= 0; num
< MAXMACRO
; num
++) {